---
layout: "default"
title: "splice"
description: "Swift documentation for 'splice': Insert newElements into x at index i."
keywords: "splice,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-splice-c_-rangereplaceablecollectiontype-s_-collectiontype-where-c-generator-element-c-generator-element-inout_-c-newelements_-s-atindex_-c-index">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-splice-c_-rangereplaceablecollectiontype-s_-collectiontype-where-c-generator-element-c-generator-element-inout_-c-newelements_-s-atindex_-c-index">func <wbr>splice&lt;C :<wbr> RangeReplaceableCollectionType, S : CollectionType where C.Generator.Element == C.Generator.Element&gt;(<wbr>inout:<wbr> C, newElements:<wbr> S, atIndex: C.Index)</a>
        
<div class="comment collapse" id="comment-func-splice-c_-rangereplaceablecollectiontype-s_-collectiontype-where-c-generator-element-c-generator-element-inout_-c-newelements_-s-atindex_-c-index"><div class="p">
    <p>Insert <code>newElements</code> into <code>x</code> at index <code>i</code></p>

<p>Invalidates all indices with respect to <code>x</code>.</p>

<p>Complexity: O(<code>count(x) + count(newElements)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func splice&lt;C : RangeReplaceableCollectionType, S : CollectionType where C.Generator.Element == C.Generator.Element&gt;(inout x: C, newElements: S, atIndex i: C.Index)</code>
    
    
</div></div>
</div>
